<?php
namespace EasyVote\EasyVoteBundle\DataFixtures\ORM;

use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\Persistence\ObjectManager;
use EasyVote\EasyVoteBundle\Entity\Department;
use EasyVote\EasyVoteBundle\Entity\DepartmentTree;

/**
 * Class LoadDepartmentData
 * Loads department data into the database
 * @package EasyVote\EasyVoteBundle\DataFixtures\ORM
 */
class LoadDepartmentData extends AbstractFixture implements OrderedFixtureInterface
{
    /**
     * {@inheritDoc}
     */
    public function load(ObjectManager $manager)
    {
        $id = 0;

        //INSERT UNIVERSITY SPECIFIC STUFF HERE.
        //College of Arts and Sciences
        $cas = new Department();
        $cas->setId(++$id);
        $cas->setName('College of Arts and Sciences');
        $cas->setDescription('College of Arts and Sciences');
        $manager->persist($cas);
        $manager->flush();

        //College of Business
        $cob = new Department();
        $cob->setId(++$id);
        $cob->setName('College of Business');
        $cob->setDescription('College of Business');
        $manager->persist($cob);
        $manager->flush();

        //College of Education
        $coEdu = new Department();
        $coEdu->setId(++$id);
        $coEdu->setName('College of Education');
        $coEdu->setDescription('College of Education');
        $manager->persist($coEdu);
        $manager->flush();

        //College of Engineering
        $coEng = new Department();
        $coEng->setId(++$id);
        $coEng->setName('College of Engineering');
        $coEng->setDescription('College of Engineering');
        $manager->persist($coEng);
        $manager->flush();

        //College of Information
        $coi = new Department();
        $coi->setId(++$id);
        $coi->setName('College of Information');
        $coi->setDescription('College of Information');
        $manager->persist($coi);
        $manager->flush();

        //College of Merchandising, Hospitality and Tourism
        $cmht = new Department();
        $cmht->setId(++$id);
        $cmht->setName('College of Merchandising, Hospitality, and Tourism');
        $cmht->setDescription('College of Merchandising, Hospitality, and Tourism');
        $manager->persist($cmht);
        $manager->flush();

        //College of Music
        $music = new Department();
        $music->setId(++$id);
        $music->setName('College of Music');
        $music->setDescription('College of Music');
        $manager->persist($music);
        $manager->flush();

        //College of Public Affairs and Community Service
        $pacs = new Department();
        $pacs->setId(++$id);
        $pacs->setName('College of Public Affairs and Community Service');
        $pacs->setDescription('College of Public Affairs and Community Service');
        $manager->persist($pacs);
        $manager->flush();

        //College of Visual Arts and Design
        $cvad = new Department();
        $cvad->setId(++$id);
        $cvad->setName('College of Visual Arts and Design');
        $cvad->setDescription('College of Visual Arts and Design');
        $manager->persist($cvad);
        $manager->flush();

        //Mayborn School of Journalism
        $mayborn = new Department();
        $mayborn->setId(++$id);
        $mayborn->setName('Mayborn School of Journalism');
        $mayborn->setDescription('Mayborn School of Journalism');
        $manager->persist($mayborn);
        $manager->flush();

        //Honors College
        $hnrs = new Department();
        $hnrs->setId(++$id);
        $hnrs->setName('Honors College');
        $hnrs->setDescription('Honors College');
        $manager->persist($hnrs);
        $manager->flush();

        //Texas Academy of Mathematics and Science
        $tams = new Department();
        $tams->setId(++$id);
        $tams->setName('Texas Academy of Mathematics and Science');
        $tams->setDescription('Texas Academy of Mathematics and Science');
        $manager->persist($tams);
        $manager->flush();

        //Toulouse Graduate School
        $tgs = new Department();
        $tgs->setId(++$id);
        $tgs->setName('Toulouse Graduate School');
        $tgs->setDescription('Toulouse Graduate School');
        $manager->persist($tgs);
        $manager->flush();

        //Now for the "sub-departments". For these, use setChildNodeOf as well. 
        //College of Engineering
        //Biomedical Engineering
        $biomed_eng = new Department();
        $biomed_eng->setId(++$id);
        $biomed_eng->setName('Department of Biomedical Engineering');
        $biomed_eng->setDescription('Department of Biomedical Engineering');
        $biomed_eng->setChildNodeOf($coEng);
        $manager->persist($biomed_eng);
        $manager->flush();

        //Computer Science and Engineering
        $cse = new Department();
        $cse->setId(++$id);
        $cse->setName('Department of Computer Science and Engineering');
        $cse->setDescription('Department of Computer Science and Engineering');
        $cse->setChildNodeOf($coEng);
        $manager->persist($cse);
        $manager->flush();

        //Electrical Engineering
        $ee = new Department();
        $ee->setId(++$id);
        $ee->setName('Department of Electrical Engineering');
        $ee->setDescription('Department of Electrical Engineering');
        $ee->setChildNodeOf($coEng);
        $manager->persist($ee);
        $manager->flush();

        //Engineering Technology
        $et = new Department();
        $et->setId(++$id);
        $et->setName('Department of Engineering Technology');
        $et->setDescription('Department of Engineering Technology');
        $et->setChildNodeOf($coEng);
        $manager->persist($et);
        $manager->flush();

        //Materials Science and Engineering
        $mse = new Department();
        $mse->setId(++$id);
        $mse->setName('Department of Materials Science and Engineering');
        $mse->setDescription('Department of Materials Science and Engineering');
        $mse->setChildNodeOf($coEng);
        $manager->persist($mse);
        $manager->flush();

        //Mechanical and Energy Engineering
        $meen = new Department();
        $meen->setId(++$id);
        $meen->setName('Department of Mechanical and Energy Engineering');
        $meen->setDescription('Department of Mechanical and Energy Engineering');
        $meen->setChildNodeOf($coEng);
        $manager->persist($meen);
        $manager->flush();

        //College of Information
        //Learning Technologies
        $lt = new Department();
        $lt->setId(++$id);
        $lt->setName('Department of Learning Technologies');
        $lt->setDescription('Department of Learning Technologies');
        $lt->setChildNodeOf($coi);
        $manager->persist($lt);
        $manager->flush();

        //Library and Information Sciences
        $lis = new Department();
        $lis->setId(++$id);
        $lis->setName('Department of Library and Information Sciences');
        $lis->setDescription('Department of Library and Information Sciences');
        $lis->setChildNodeOf($coi);
        $manager->persist($lis);
        $manager->flush();

        //Other departments go here.
    }

    /**
     * {@inheritDoc}
     */
    public function getOrder()
    {
        return 3; // the order in which fixtures will be loaded
    }
}

?>
